package com.ruoyi.business.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.business.domain.EquipmentRealData;
import com.ruoyi.business.service.IEquipmentRealDataService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 设备实时采集数据Controller
 * 
 * @author DL
 * @date 2025-06-23
 */
@RestController
@RequestMapping("/data")
public class EquipmentRealDataController extends BaseController
{
    @Autowired
    private IEquipmentRealDataService equipmentRealDataService;

    /**
     * 查询设备实时采集数据列表
     */
    //@RequiresPermissions("business:data:list")
    @GetMapping("/list")
    public TableDataInfo list(EquipmentRealData equipmentRealData)
    {
        startPage();
        List<EquipmentRealData> list = equipmentRealDataService.selectEquipmentRealDataList(equipmentRealData);
        return getDataTable(list);
    }

    /**
     * 导出设备实时采集数据列表
     */
    //@RequiresPermissions("business:data:export")
    @Log(title = "设备实时采集数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EquipmentRealData equipmentRealData)
    {
        List<EquipmentRealData> list = equipmentRealDataService.selectEquipmentRealDataList(equipmentRealData);
        ExcelUtil<EquipmentRealData> util = new ExcelUtil<EquipmentRealData>(EquipmentRealData.class);
        util.exportExcel(response, list, "设备实时采集数据数据");
    }

    /**
     * 获取设备实时采集数据详细信息
     */
    //@RequiresPermissions("business:data:query")
    @GetMapping(value = "/{equipmentId}")
    public AjaxResult getInfo(@PathVariable("equipmentId") String equipmentId)
    {
        return success(equipmentRealDataService.selectEquipmentRealDataByEquipmentId(equipmentId));
    }

    /**
     * 新增设备实时采集数据
     */
    //@RequiresPermissions("business:data:add")
    @Log(title = "设备实时采集数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EquipmentRealData equipmentRealData)
    {
        return toAjax(equipmentRealDataService.insertEquipmentRealData(equipmentRealData));
    }

    /**
     * 修改设备实时采集数据
     */
    //@RequiresPermissions("business:data:edit")
    @Log(title = "设备实时采集数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EquipmentRealData equipmentRealData)
    {
        return toAjax(equipmentRealDataService.updateEquipmentRealData(equipmentRealData));
    }

    /**
     * 删除设备实时采集数据
     */
    //@RequiresPermissions("business:data:remove")
    @Log(title = "设备实时采集数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{equipmentIds}")
    public AjaxResult remove(@PathVariable String[] equipmentIds)
    {
        return toAjax(equipmentRealDataService.deleteEquipmentRealDataByEquipmentIds(equipmentIds));
    }
}
